package com.archie.xunji.map.tools;

import android.os.AsyncTask;
import com.archie.xunji.map.SetOnGetResult;

import java.io.IOException;
import java.util.HashMap;

/**
 * Created by Administrator on 2015/11/10.
 */
public final class HttpAsyncTask extends AsyncTask<String,Void,String>{

    private HashMap<String,String> httpParams;

    private String encode;

    private SetOnGetResult setOnGetResult;

    public HttpAsyncTask(HashMap<String,String> httpParams,String encode,SetOnGetResult setOnGetResult){
        this.httpParams = httpParams;
        this.encode = encode;
        this.setOnGetResult = setOnGetResult;
    }

    @Override
    protected String doInBackground(String... params) {
        String ret = null;

        if(params != null){

            try {
                ret = HttpUtils.sendByPost(params[0],httpParams,encode);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        return ret;
    }

    @Override
    protected void onPostExecute(String s) {
        super.onPostExecute(s);

        setOnGetResult.onGetResult(s);
    }
}
